/**
 * Created by issuser on 2016/9/9.
 */
'use strict';

app.controller('PersonalCtrl',
    ['$scope', 'dialogs', 'PersonalService',
        function($scope, dialogs, PersonalService){
            var vm = $scope.vm = this;
            var userId=angular.copy($scope.app.loginUser.id);
            if(!ISS.isEmpty(userId)){
                PersonalService.initUpdate(userId).then(function(data){
                        if(data.success === false){
                            dialogs.notify(data);
                        }else{
                            vm.user =  data;
                            delete vm.user.createTime;
                            delete vm.user.fax;
                            delete vm.user.archs;
                        }
                    });
            }

            vm.saveUser=function () {
                PersonalService.updateCurrUser(vm.user).then(function(data){
                        dialogs.notify(data);
                    });
            }

            vm.savePassword=function () {
                PersonalService.updatePassword(vm.user).then(function(data){
                    dialogs.notify(data);
                });
            }
        }]);